package com.jl.jlapp.mvp.activity;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.JavascriptInterface;
import android.webkit.JsResult;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.Toast;
import butterknife.BindView;
import butterknife.ButterKnife;

import com.jl.jlapp.R;
import com.jl.jlapp.popu.ClearHistorySearhPopu;
import com.jl.jlapp.utils.Tools;

public class MyAddressActivity
  extends Activity
{
  @BindView(R.id.address_list_return)
  ImageView addressListReturn;
  ClearHistorySearhPopu clearHistorySearhPopu;
  Boolean isCheckAddOrEdit = Boolean.valueOf(false);
  @BindView(R.id.my_address_web)
  WebView myAddressWeb;
  int userId = 0;
  
  public void init()
  {
    WebSettings localWebSettings = this.myAddressWeb.getSettings();
    localWebSettings.setSaveFormData(false);
    localWebSettings.setLoadWithOverviewMode(true);
    localWebSettings.setJavaScriptEnabled(true);
    localWebSettings.setSupportZoom(true);
    localWebSettings.setUseWideViewPort(true);
    localWebSettings.setDomStorageEnabled(true);
    localWebSettings.setJavaScriptCanOpenWindowsAutomatically(true);
    localWebSettings.setLoadWithOverviewMode(true);
    this.myAddressWeb.setWebViewClient(new WebViewClient());
    this.myAddressWeb.addJavascriptInterface(new DemoJavaScriptInterface(), "Android");
    this.myAddressWeb.loadUrl("http://117.158.178.202:8001/JLMIS/junlin/mis_jsp/webview/address.jsp?userId=" + this.userId);
  }
  
  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(R.layout.activity_my_address);
    ButterKnife.bind(this);
    Tools.addActivity(this);
    this.userId = getSharedPreferences("JLAppData", 0).getInt("userId", 0);
    if (this.userId > 0)
    {
      init();
      this.addressListReturn.setOnClickListener(new OnClickListener()
      {
        public void onClick(View paramAnonymousView)
        {
          if (MyAddressActivity.this.isCheckAddOrEdit.booleanValue())
          {
            MyAddressActivity.this.clearHistorySearhPopu = new ClearHistorySearhPopu(MyAddressActivity.this, new OnClickListener()
            {
              public void onClick(View paramAnonymous2View)
              {
                MyAddressActivity.this.clearHistorySearhPopu.dismiss();
                MyAddressActivity.this.finish();
              }
            }, Integer.valueOf(9));
            MyAddressActivity.this.clearHistorySearhPopu.showAtLocation(MyAddressActivity.this.findViewById(R.id.my_address_page), 17, 0, 0);
            return;
          }
          Tools.finishAll();
        }
      });
      return;
    }
    Toast.makeText(this, "您还未登录，请先登录。", Toast.LENGTH_SHORT).show();
    startActivity(new Intent(this, LoginActivity.class));
  }
  
  public boolean onKeyDown(int paramInt, KeyEvent paramKeyEvent)
  {
    if (paramInt == 4) {
      Tools.finishAll();
    }
    return super.onKeyDown(paramInt, paramKeyEvent);
  }
  
  final class DemoJavaScriptInterface
  {
    DemoJavaScriptInterface() {}
    
    @JavascriptInterface
    public int GetLat()
    {
      return MyAddressActivity.this.userId;
    }
    
    @JavascriptInterface
    public void clickOnAndroid(String paramString)
    {
      Toast.makeText(MyAddressActivity.this, paramString, Toast.LENGTH_SHORT).show();
    }
    
    @JavascriptInterface
    public void hrefToChooseAddressPage()
    {
      Toast.makeText(MyAddressActivity.this, "加载了", Toast.LENGTH_LONG).show();
    }
    
    @JavascriptInterface
    public void isCheckAddOrEdit(String paramString)
    {
      Log.d("aaaaasssssssssssss", "isUpdate:" + paramString);
      if ("true".equals(paramString)) {}
      for (MyAddressActivity.this.isCheckAddOrEdit = Boolean.valueOf(true);; MyAddressActivity.this.isCheckAddOrEdit = Boolean.valueOf(false))
      {
        Log.d("aaaaasssssssssssss", "CheckAddOrEdit:" + paramString);
        return;
      }
    }
  }
  
  final class MyWebChromeClient
    extends WebChromeClient
  {
    MyWebChromeClient() {}
    
    public boolean onJsAlert(WebView paramWebView, String paramString1, String paramString2, JsResult paramJsResult)
    {
      Log.d("webview", paramString2);
      paramJsResult.confirm();
      return true;
    }
  }
}


/* Location:              /Users/davidzhang/Documents/decompileApk/jlfood-dex2jar.jar!/com/jl/jlapp/mvp/activity/MyAddressActivity.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */